#####################################################################
# File:         GroupListeners.py
# Product:      KnowledgeEngine
#
# Copyright:    Copyright (c) 2002, Faulkner Ltd.
# Author:       Brian Oliver
#
# Description:  This file defines the GroupListeners class to
#               manage a collection of registered MessageListeners
#               for a specified Group.
#
# Note:         Topic, Filter and Group names are case-sensitive
#
# See Also:     Messaging, Message, MessageListener, TopicsListeners,
#               FilterListeners
#####################################################################

#####################################################################
## KnowledgeEngine Library Imports
from TopicListeners import *

#####################################################################
## Zope Library Imports
# (none)
 
#####################################################################
## Python Library Imports
# (none)

#####################################################################
## GroupListeners Class Definition
class GroupListeners(TopicListeners):
    """
        A class to that stores the registered MessageListeners
        for a particular named Group.
    """
        
    #---------------------------------------------------------------#
    
    #topics, groups or filters that belong to this group
    names = {}      #{name:None}  
    
    #---------------------------------------------------------------#

    def __init__(self, name, names = []):
        """
            Constructor for the Group
        """
        
        TopicListeners.__init__(self, name)
        self.names = {}
        
        for n in names:
            self.addName(n)
        
    #---------------------------------------------------------------#

    def addName(self, name):
        """
            Adds the specified name to the group
        """

        if not self.names.has_key(name):
            self.names[name] = None

    #---------------------------------------------------------------#

    def containsName(self, name):
        """
            Determines if the specified name is in the group
        """
        return self.names.has_key(name)

    #---------------------------------------------------------------#

#####################################################################
## Class Initialisation
# (none)
